package edu.fub.pub2search.app;

/**
 * Class providing a cache for preference saving previous selected preferences
 * of user. It uses the singleton pattern to ensure
 * that only one instance of the class will exist in a given application.
 * 
 * @author Andrej
 */
public class SavedPreference {
	
	/** Variables for saving state of preferences */
	private int hour;
	private int min;
	private boolean beer;
	private boolean dancefloor;
	private boolean livemusic;
	private boolean nosmoking;
	
	/**
	 * Private constructor.
	 */
	private SavedPreference() {
		resetContent();
	}
	
	/**
	 * SingletonHolder is loaded on the first execution of Singleton.getInstance() 
	 * or the first access to SingletonHolder.INSTANCE, not before.
	 */
	private static class SingletonHolder { 
		private final static SavedPreference INSTANCE = new SavedPreference();
	}
	
	/** 
	 * Static 'instance' method. 
	 */
	public static SavedPreference getInstance(){
		return SingletonHolder.INSTANCE;
	}
	
	/** Method for get previous saved preference of beer */
	public boolean getBeer() {
		return beer;
	}
	
	/** Method for get previous saved preference of live music */
	public boolean getLivemusic (){
		return livemusic;
	}

	/** Method for get previous saved preference of dance floor */
	public boolean getDancefloor (){
		return dancefloor;
	}
	
	/** Method for get previous saved preference of no smoking */
	public boolean getNosmoking (){
		return nosmoking;
	}
	
	/** Method for get previous preferred opening hour */
	public int getHour (){
		return hour;
	}
	
	/** Method for get previous preferred opening minute */
	public int getMin (){
		return min;
	}
	
	/** 
	 * Method for setting beer preference
	 * 
	 * @param bool
	 */
	public void setBeer(boolean bool){
		beer = bool;
	}
	
	/**
	 * Method for setting live music preference
	 * 
	 * @param bool
	 */
	public void setLivemusic(boolean bool){
		livemusic = bool;
	}
	
	/**
	 * Method for setting dance floor preference
	 * 
	 * @param bool
	 */
	public void setDancefloor(boolean bool){
		dancefloor = bool;
	}
	
	/**
	 * Method for setting no smoking preference
	 * 
	 * @param bool
	 */
	public void setNosmoking (boolean bool){
		nosmoking = bool;
	}
	
	/**
	 * Method for setting opening hour preference
	 * 
	 * @param i hour
	 */
	public void setHour (int i){
		hour = i;
	}
	
	/**
	 * Method for setting opening min preference
	 * 
	 * @param i min
	 */
	public void setMin (int i){
		min = i;
	}
	
	/**
	 * Method for setting default value for preferences
	 */
	public void resetContent() {
		hour = 0;
		min = 0;
		beer = false;
		dancefloor = false;
		livemusic = false;
		nosmoking = false;
	}
	
}